<extend name="Member:base" />
<block name="title"><title>心心向善-账户信息</title></block>
		<!-- 头部结束-->
<block name="body">

			<!--<主要区块>-->
			<div class="right-layout">
				<div class="wrap">
					<div class="tabmenu">
						<ul class="tab pngFix">
							<li class="normal">
								<a href="/member/shdz.html">地址列表</a>
							</li>
							<li class="active">
								<a href="/member/xgdz.html">编辑地址</a>
							</li>
						</ul>
					</div>
					<div class="alert alert-success">
						<h4>操作提示：</h4>
						<ul>
							<li>1. 修改收货地址，有助于提高发货的准确性，购物时需要选择收货地址。</li>
						</ul>
					</div>
					<div class="ncm-default-form">
						<form id="email_form" action="xgdz" method="post">
							<input type="hidden" name="form_submit" value="ok">
							<input type="hidden" name="id" value="{$list.id}">
							<dl>
								<dt><i class="required">*</i>收货人：</dt>
								<dd>
									<input type="text" class="text w180" maxlength="40" value="{$list.realname}" name="true_name">
									<p class="hint">请填写真实姓名</p>
								</dd>
							</dl>
							<dl>
								<dt><i class="required">*</i>所在地区：</dt>
								<dd>
									    <select name="province" id="code">
											<if condition="$list.province eq ''" >
											<option >请选择省份</option>
											<else/>
											<option value="{$list.province}">{$list.province}</option>
											</if>
										
										<volist name="code" id="vo">						
											  <option value ="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option>						
										</volist>
										</select>

										<select id="cobb" name="city">
											<if condition="$list.city eq ''" >
											<option ></option>
											<else/>
											<option value="{$list.city}">{$list.city}</option>
											</if>	

										<volist name="citylist" id="vo">						
											  <option value ="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option>						
										</volist>
										</select>
										
										<select id="cocc" name="area">
											<if condition="$list.area eq ''" >
											<option ></option>
											<else/>
											<option value="{$list.area}">{$list.area}</option>
											</if>

										<volist name="cityson" id="vo">						
											  <option value ="{$vo.area_name}" data-id="{$vo.area_id}">{$vo.area_name}</option>						
										</volist>					
										</select>
								</dd>
							</dl>
							<dl>
								<dt><i class="required">*</i>街道地址：</dt>
								<dd>
									<input type="text" class="text w180" maxlength="40" value="{$list.address}" name="address">
									<p class="hint">不必重复填写地区</p>
								</dd>
							</dl>
							<dl>
								<dt><i class="required">*</i>电话号码：</dt>
								<dd>
									<input type="text" class="text w180" maxlength="40" value="{$list.tel_phone}" name="tel_phone">
									<p class="hint">区号 - 电话号码 - 分机</p>
								</dd>
							</dl>
							<dl>
								<dt><i class="required">*</i>手机号码：</dt>
								<dd>
									<input type="text" class="text w180" maxlength="40" value="{$list.mob_phone}" name="mob_phone">
								</dd>
							</dl>
							<dl>
								<dt><i class="required"></i>设为默认地址：</dt>
								<dd>
								<if condition="$list.is_default eq '0'" >
									<input type="checkbox" class="checkbox vm mr5" name="is_default" id="is_default" value="1">
								<else/>
								    <input type="checkbox" class="checkbox vm mr5" name="is_default" id="is_default" value="1" checked="true">
								</if>
									<label for="is_default">设置为默认收货地址 <span style="color:red">(默认收货地址只能有一个)</span></label>
								</dd>
							</dl>
							<dl class="bottom">
								<dt>&nbsp;</dt>
								<dd><label class="submit-border">
						  <input type="hidden" name="xgaddresshash" id="xgaddresshash" value="">
				          <input type="submit" class="submit" value="提交"></label>
								</dd>
							</dl>
						</form>
					</div>
				</div>
			</div>
			<!--</主要区块>-->
			<div class="clear"></div>
		</div>
	<script>
        $('#code').change(function(){
			var name = $(this).val();
            var code = $(this).find("option[value='"+name+"']").attr("data-id");
			var url = '{:U("/shop/code_chage")}';
			//alert(code);
			if (code) {			
				$.ajax({
					url:url,
					data:{id:code},
					type:'post',
					//dataType:'json',
					success:function (data) {
						var a = data;
						var html = '';
						for(var i=0;i<a.length;i++ ) {
							
							html += '<option value ="'+a[i].area_name+'" data-id="'+a[i].area_id+'">'+a[i].area_name+'</option>';
						}
						
						 $("#cobb").html(html);						
					}
				});
				var parent =$(this).val();
				$.ajax({
					url:url,
					data:{id:code,parent:parent},
					type:'post',
					//dataType:'json',
					success:function (data) {
						var a = data;
						var html2 = '';
						for(var i=0;i<data.length;i++ ) {
							
							html2 += '<option value ="'+data[i].area_name+'" data-id="'+data[i].area_id+'">'+data[i].area_name+'</option>';
						}
						//alert(html);
						 $("#cocc").html(html2);						
					}
				});					
			}
			

        });
		
        $('#cobb').change(function(){
			var name = $(this).val();
            var code = $(this).find("option[value='"+name+"']").attr("data-id");
			//alert(code);
			var url = '{:U("/shop/code_chage")}';
			if (code) {			
				$.ajax({
					url:url,
					data:{id:code},
					type:'post',
					//dataType:'json',
					success:function (data) {
						var a = data;
						var html2 = '';
						for(var i=0;i<data.length;i++ ) {
							
							html2 += '<option value ="'+data[i].area_name+'" data-id="'+data[i].area_id+'">'+data[i].area_name+'</option>';
						}
						
						 $("#cocc").html(html2);						
					}
				});					
			}
        });		
    </script>
	<script type="text/javascript">
	$(function(){

		$('input').change(function(){
			$("#xgaddresshash").val(_getRandomString(32));

		});
		$('select').change(function(){
			$("#xgaddresshash").val(_getRandomString(32));
		});
	});
	

	// 获取长度为len的随机字符串  
	function _getRandomString(len) {  
		len = len || 32;  
		var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1  
		var maxPos = $chars.length;  
		var pwd = '';  
		for (i = 0; i < len; i++) {  
			pwd += $chars.charAt(Math.floor(Math.random() * maxPos));  
		}  
		return pwd;  
	} 
  </script>
	</block>